include ../Makefile.inc

CPPFLAGS += -I$(PILO_DIR)/output/include/core -I$(PILO_DIR)/core-test
LIBS += -L$(PILO_DIR)/out/lib -lpilocore_$(ARCH).a $(SYS_LIBS)

TmpOutDir = $(PILO_PROJECT_DIR)/$(ARCH)

CoreTestSrcDir := $(PILO_DIR)/core-test
CoreTestSources := $(shell find -P $(CoreTestSrcDir) -name "*.cpp" -exec basename {} \;)
CoreTestObjects := $(CoreTestSources:.cpp=.o)
CoreTestDepends := $(CoreTestObjects:.o=.d)
BinCoreTest = core-test

VPATH := $(CoreTestSrcDir)/common:$(CoreTestSrcDir)/containers:$(CoreTestSrcDir)/ipc:$(CoreTestSrcDir)/memory:$(CoreTestSrcDir)/string:$(CoreTestSrcDir)/thread


core-test : $(CoreTestObjects)
	@if [ ! -d $(TmpOutDir) ] ; \
        then \
                echo "Creating output dir -> $(TmpOutDir) ..."; \
                $(MKDIR) -p $(TmpOutDir); \
        fi
	$(LD) $(LDFALGS) -o $@ $^ $(LIBS)

depend : $(CoreTestDepends)
$(CoreTestDepends): %.d:%.cpp
	@set -e; rm -f $@; \
	$(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
	sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
	rm -f $@.$$$$
sinclude $(CoreTestDepends)



.PHONY: clean

install:
	$(INSTALL) -D $(TmpOutDir)/$(LibCoreStatic) $(OUTPUT_LIB_DIR)/
	
	@if [ ! -d $(OUTPUT_INC_DIR)/core/common ] ; \
        then \
                $(MKDIR) -p $(OUTPUT_INC_DIR)/core/common; \
        fi
	$(INSTALL) $(CoreSrcDir)/common/*.h $(OUTPUT_INC_DIR)/core/common/
	
clean:
	$(RM) -f *.d
	$(RM) -f *.d.*
	$(RM) -f $(CoreTestObjects)
	$(RM) -f $(CoreTestDepends)

debug : 
	echo $(CoreTestObjects) 
	echo "---------------------------"
	echo $(CoreTestSources)
	echo "---------------------------"
	echo $(CoreTestDepends)
	echo "----------------------------"
	echo $(VPATH)
	echo "-----------------------------"
	@echo "project dir ==> $(PILO_PROJECT_DIR)"
	@echo "solution dir ==> $(PILO_SOLUTION_DIR)"
	@echo "pilo dir ==> $(PILO_DIR)"
	@echo "sp inc ==>$(PILO_DIR)/output/include"


